package top.hcode.hoj.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.dto.BaseIdDTO;
import top.hcode.hoj.pojo.dto.QuerySampleDTO;
import top.hcode.hoj.pojo.entity.coll.CollUserAnswer;
import top.hcode.hoj.service.admin.AdminCollUserAnswerService;

/**
 * @author orangej
 * @since 2025-02-09
 */
@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AdminCollUserAnswerController {

    private final AdminCollUserAnswerService userAnswerService;

    @GetMapping("/admin/coll-user-answer/list")
    public CommonResult<IPage<CollUserAnswer>> getCollUserAnswerList(QuerySampleDTO querySampleDTO) {
        return CommonResult.successResponse(userAnswerService.getCollUserAnswerList(querySampleDTO));
    }

    @PostMapping("/admin/coll-user-answer/save")
    public CommonResult<CollUserAnswer> saveCollUserAnswer(@RequestBody CollUserAnswer userAnswer) {
        return CommonResult.successResponse(userAnswerService.saveCollUserAnswer(userAnswer));
    }

    @PostMapping("/admin/coll-user-answer/delete")
    public CommonResult<Void> deleteCollUserAnswer(@RequestBody BaseIdDTO dto) {
        userAnswerService.deleteCollUserAnswer(dto.getId());
        return CommonResult.successResponse();
    }

}
